<?php

namespace App\Services\User;

use App\services\User\RoleGroup\RoleGroupLogic;
/**
 * 角色管理的逻辑层
 */
class RoleGroup
{

    // 增加一个角色组
    public function add($data): array
    {

        $data = init_array($data,['name' => ' ', 'role_ids' => ' ']);

        return (new RoleGroupLogic())->add($data);
    }
    // 禁用一个角色组
    public function stop($data): array
    {
        return (new RoleGroupLogic())->stop($data);

    }
    // 获取角色组列表分页数据
    public function list($data): array
    {
        $data = init_array($data,['page' => 1, 'list_rows' => '']);

        return (new RoleGroupLogic())->list($data);
    }
    // 修改角色组资料
    public function edit($data): array
    {
        if(!isset($data['name']) && !isset($data['role_ids'])){

            return verify_err($data, 'name,role_ids参数至少要传一个');
        }
        return (new RoleGroupLogic())->edit($data);
    }
//    // 将roleGroupIds解释成role_ids
//    public function roleGroupIdsToRoleIds(): array
//    {
//        $data = $this->haveIssetReceiveData(['group_ids' => '0']);
//        if ('0' === $data['group_ids']) {
//            return verify_err(null, '请传ids参数');
//        };
//        return $this->stepRun($data, 'roleGroupIdsToRoleIds', 'roleGroupIdsToRoleIds');
//    }
}
